package com.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AnnoAdive {
    //切点
    @Pointcut("execution(* com.dao.impl..UserDaoImpl.*(..))")
    public void pointcut() {
    }

    @Before("pointcut()")
    public void before(JoinPoint joinPoint) {
        System.out.println("这是前置通知");
        System.out.println("目标类是：" + joinPoint.getTarget());
        System.out.println("，被植入增强处理方法为：" + joinPoint.getSignature().getName());
    }

    @AfterReturning("pointcut()")
    public void afterReturning(JoinPoint joinPoint) {
        System.out.println("这是返回通知");
        System.out.println("目标类是：" + joinPoint.getTarget());
        System.out.println("，被植入增强处理方法为：" + joinPoint.getSignature().getName());
    }
}


